//****************************************************************
//   Thermo Grenade
//****************************************************************
class TFTGrenade extends TFWeapon
    config(user);

simulated function Tick(float dt)
{
    if(!HasAmmo())
	{
	    tfpri(pawn(owner).playerreplicationinfo).usedcredits -=500;
        DetachFromPawn(instigator);
        Instigator.DeleteInventory(self);
        instigator.controller.SwitchToBestWeapon();
        Destroy();
    }
}

function byte BestMode()
{
	return 0;
}

function float SuggestAttackStyle()
{
    return -1;
}

function float SuggestDefenseStyle()
{
    return -1;
}

function float RangedAttackTime()
{
	return 0.2;
}

function bool RecommendRangedAttack()
{
	return True;
}

function bool RecommendLongRangedAttack()
{
	return False;
}



simulated function float ChargeBar()
{
	return FMin(1,(GetFireMode(0).HoldTime+GetFireMode(1).HoldTime)/(TGrenadeFire(GetFireMode(0)).mHoldClampMax));
}

simulated event RenderOverlays( Canvas Canvas )
{
    local int m;
	local vector NewScale3D;
//	local rotator CenteredRotation;

    if (Instigator == None)
        return;

	if ( Instigator.Controller != None )
		Hand = Instigator.Controller.Handedness;

    if ((Hand < -1.0) || (Hand > 1.0))
        return;

    Canvas.DrawActor(None, false, true);

    for (m = 0; m < NUM_FIRE_MODES; m++)
    {
        if (FireMode[m] != None)
        {
            FireMode[m].DrawMuzzleFlash(Canvas);
        }
    }

	newScale3D = Default.DrawScale3D;
	SetDrawScale3D(newScale3D);

	PlayerViewPivot.Roll = Default.PlayerViewPivot.Roll;
	PlayerViewPivot.Yaw = Default.PlayerViewPivot.Yaw;

	PlayerViewOffset = Default.PlayerViewOffset;

    SetLocation( Instigator.Location + Instigator.CalcDrawOffset(self) );
    SetRotation( Instigator.GetViewRotation() );

    bDrawingFirstPerson = true;
    Canvas.DrawActor(self, false, false, DisplayFOV);
    bDrawingFirstPerson = false;
}

function DropFrom(vector StartLocation)
{
    local int m;
	local Pickup Pickup;

    if (!bCanThrow || !HasAmmo())
        return;

    ClientWeaponThrown();

    for (m = 0; m < NUM_FIRE_MODES; m++)
    {
        if (FireMode[m].bIsFiring)
            StopFire(m);
    }

	if ( Instigator != None )
	{
		DetachFromPawn(Instigator);
	}

	if (instigator.Health>0)
	Pickup = Spawn(PickupClass,,, StartLocation);
	if (instigator.Health<=0)
	{
	Pickup = None;
	Spawn(class'TGrenadeAltProj',,, StartLocation);
	}
	if ( Pickup != None )
	{
    	Pickup.InitDroppedPickupFor(self);
	    Pickup.Velocity = Velocity;
        if (Instigator.Health > 0)
            WeaponPickup(Pickup).bThrown = true;
    }

    Destroy();
}

simulated function bool UpdateRoll(float dt)
{return false;}

defaultproperties
{
     FireModeClass(0)=Class'Taskforces.TGrenadeFire'
     FireModeClass(1)=Class'Taskforces.TGrenadeAltFire'
     SelectAnim=
     PutDownAnim=
     SelectSound=Sound'GeneralAmbience.beep5'
     AIRating=1.500000
     CurrentRating=1.500000
     bShowChargingBar=True
     bNoAmmoInstances=False
     Priority=11
     InventoryGroup=0
     GroupOffset=6
     PickupClass=Class'Taskforces.TGrenadePickup'
     PlayerViewOffset=(X=16.000000,Y=14.000000,Z=-10.000000)
     BobDamping=1.400000
     AttachmentClass=Class'Taskforces.TGrenadeAttach'
     IconMaterial=Texture'TFMedia.General.ArkonHUD'
     IconCoords=(X1=9,Y1=115,X2=46,Y2=154)
     ItemName="T-Grenade"
     DrawType=DT_StaticMesh
     StaticMesh=StaticMesh'TFMedia.DGrenade'
     DrawScale=0.450000
     Skins(0)=Texture'TFMedia.TGrenade.ThermoGrenadeTex1'
     Skins(1)=Shader'AWGlobal.Shaders.CybShader'
     Skins(2)=Texture'HumanoidArchitecture.Borders.bdr01bHA'
     Skins(3)=Texture'HumanoidArchitecture.Floors.flr01HA'
     bDoAmmoRegen=False
     SkillCost=500
}
